from src.Page.Page import Page
import pytest,yaml
from selenium import webdriver

def read_yaml():
    with open(r'D:\Pycharm_Django\PyCharm\Data_10_12\src\Utils\read_yaml.yaml',encoding='utf-8') as p:
        return yaml.safe_load(p)

# # 简化多浏览器fixture
# @pytest.fixture(params=['edge', 'chrome', 'firefox'])  # 现在测试三种浏览器
# def driver(request):
#     if request.param == 'chrome':
#         driver = webdriver.Chrome()
#     elif request.param == 'firefox':
#         driver = webdriver.Firefox()
#     else:  # 默认使用edge
#         driver = webdriver.Edge()
#     yield driver
#     driver.close()

@pytest.fixture()
def driver():
    driver = webdriver.Edge()
    yield driver
    driver.close()
@pytest.mark.parametrize('data',read_yaml())
def test_baidus_01(driver,data):
    po = Page(driver)
    po.test_baidu_01(data.get('neirong'))
